/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * msnCambiarContraseña.java
 *
 * Created on 31/08/2011, 03:44:18 PM
 */
package UI;

import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.logging.Level;
import java.util.logging.Logger;
import msnclient.Controladora;

/**
 *
 * @author Agustin
 */
public class msnCambiarContraseña extends javax.swing.JFrame {

    /** Creates new form msnCambiarContraseña */
    public msnCambiarContraseña() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblTitulo = new javax.swing.JLabel();
        lblContraseña = new javax.swing.JLabel();
        txtContraseña = new javax.swing.JPasswordField();
        lblContraseñaRE = new javax.swing.JLabel();
        txtContraseñare = new javax.swing.JPasswordField();
        btnCambiarContraseña = new javax.swing.JButton();
        separadorEstado = new javax.swing.JSeparator();
        BarraEstado = new javax.swing.JTextField();
        lblCambiarContraseña = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        lblTitulo.setFont(new java.awt.Font("Tw Cen MT", 0, 48));
        lblTitulo.setText("mm@il");
        lblTitulo.setName("lblTitulo"); // NOI18N

        lblContraseña.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblContraseña.setText("Contraseña Vieja");
        lblContraseña.setName("lblContraseña"); // NOI18N

        txtContraseña.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtContraseña.setName("txtContraseña"); // NOI18N

        lblContraseñaRE.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblContraseñaRE.setText("Contraseña Nueva");
        lblContraseñaRE.setName("lblContraseñaRE"); // NOI18N

        txtContraseñare.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtContraseñare.setName("txtContraseñare"); // NOI18N

        btnCambiarContraseña.setText("Cambiar Contraseña");
        btnCambiarContraseña.setName("btnCambiarContraseña"); // NOI18N
        btnCambiarContraseña.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCambiarContraseñaActionPerformed(evt);
            }
        });

        separadorEstado.setName("separadorEstado"); // NOI18N

        BarraEstado.setEnabled(false);
        BarraEstado.setName("BarraEstado"); // NOI18N

        lblCambiarContraseña.setFont(new java.awt.Font("Tahoma", 0, 18));
        lblCambiarContraseña.setText("Cambiar Contraseña");
        lblCambiarContraseña.setName("lblCambiarContraseña"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(121, 121, 121)
                .addComponent(lblTitulo, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                .addGap(111, 111, 111))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BarraEstado, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
                    .addComponent(separadorEstado, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(90, 90, 90)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addComponent(btnCambiarContraseña, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(43, 43, 43))
                    .addComponent(txtContraseñare, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                    .addComponent(lblContraseñaRE, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                    .addComponent(txtContraseña, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                    .addComponent(lblContraseña, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE))
                .addGap(81, 81, 81))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(101, 101, 101)
                .addComponent(lblCambiarContraseña, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                .addGap(70, 70, 70))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblTitulo)
                .addGap(18, 18, 18)
                .addComponent(lblCambiarContraseña)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
                .addComponent(lblContraseña)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtContraseña, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(lblContraseñaRE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtContraseñare, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addComponent(btnCambiarContraseña)
                .addGap(18, 18, 18)
                .addComponent(separadorEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BarraEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCambiarContraseñaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCambiarContraseñaActionPerformed
        String contraseña = "";
        String contraseñare = "";
        for (int i = 0; i < txtContraseña.getPassword().length; i++) {
            contraseña = contraseña + txtContraseña.getPassword()[i];
        }
        for (int i = 0; i < txtContraseñare.getPassword().length; i++) {
            contraseñare = contraseñare + txtContraseñare.getPassword()[i];
        }
        try {
            BarraEstado.setText(Controladora.getInstancia().cambiarDatosPersonales("", contraseñare, contraseña));
            if (BarraEstado.getText().equals("Se cambio correctamente la contraceña")) {
                this.dispose();
                msnConectado.getInstancia().setVisible(true);
            }
        } catch (RemoteException ex) {
            Logger.getLogger(msnCambiarContraseña.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NotBoundException ex) {
            Logger.getLogger(msnCambiarContraseña.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_btnCambiarContraseñaActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new msnCambiarContraseña().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField BarraEstado;
    private javax.swing.JButton btnCambiarContraseña;
    private javax.swing.JLabel lblCambiarContraseña;
    private javax.swing.JLabel lblContraseña;
    private javax.swing.JLabel lblContraseñaRE;
    private javax.swing.JLabel lblTitulo;
    private javax.swing.JSeparator separadorEstado;
    private javax.swing.JPasswordField txtContraseña;
    private javax.swing.JPasswordField txtContraseñare;
    // End of variables declaration//GEN-END:variables
}
